/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */ 
package test.rockon.fuzzy;

import junit.framework.TestCase;
import de.rockon.fuzzy.controller.model.FuzzyController;
import de.rockon.fuzzy.controller.model.FuzzyVariable;
import de.rockon.fuzzy.controller.model.enums.VariableType;

/**
 * Testet alle Methoden der FuzzyVariable
 */
public class FuzzyControllerGetInputOutputChildren extends TestCase {
	private FuzzyController fuzzySetContainer;
	private FuzzyVariable input1;
	private FuzzyVariable input2;
	private FuzzyVariable input3;
	private FuzzyVariable input4;
	private FuzzyVariable output1;
	private FuzzyVariable output2;
	private FuzzyVariable output3;
	private FuzzyVariable output4;
	private FuzzyVariable output5;
	private FuzzyVariable output6;

	private void control() {
		System.out.println("-------- Control --------");
		for (int i = 0; i < fuzzySetContainer.size(); i++) {
			if (fuzzySetContainer.getChild(i).getType() == VariableType.INPUT) {
				System.out.print(" I");
			} else {
				System.out.print(" O");
			}
			System.out.print(fuzzySetContainer.getChild(i));
		}
		System.out.println();
	}

	/**
	 * Vorbedingungen erstellen
	 */
	@Override
	protected void setUp() throws Exception {
		fuzzySetContainer = FuzzyController.getInstance();

		input1 = new FuzzyVariable("0", VariableType.INPUT, "cm", new double[] { -10, 80 });
		output1 = new FuzzyVariable("1", VariableType.OUTPUT, "cm", new double[] { -10, 80 });
		output2 = new FuzzyVariable("2", VariableType.OUTPUT, "cm", new double[] { -10, 80 });
		input2 = new FuzzyVariable("3", VariableType.INPUT, "cm", new double[] { -10, 80 });
		output3 = new FuzzyVariable("4", VariableType.OUTPUT, "cm", new double[] { -10, 80 });
		output4 = new FuzzyVariable("5", VariableType.OUTPUT, "cm", new double[] { -10, 80 });
		output5 = new FuzzyVariable("6", VariableType.OUTPUT, "cm", new double[] { -10, 80 });
		input3 = new FuzzyVariable("7", VariableType.INPUT, "cm", new double[] { -10, 80 });
		output6 = new FuzzyVariable("8", VariableType.OUTPUT, "cm", new double[] { -10, 80 });
		input4 = new FuzzyVariable("9", VariableType.INPUT, "cm", new double[] { -10, 80 });

		fuzzySetContainer.add(input1);
		fuzzySetContainer.add(input2);
		fuzzySetContainer.add(input3);
		fuzzySetContainer.add(input4);

		fuzzySetContainer.add(output1);
		fuzzySetContainer.add(output2);
		fuzzySetContainer.add(output3);
		fuzzySetContainer.add(output4);
		fuzzySetContainer.add(output5);
		fuzzySetContainer.add(output6);
	}

	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
		fuzzySetContainer.clear();
	}

	/**
	 * TODO: Test noch asserts geben
	 */
	public void testRandom() {
		System.out.println("-------- Random --------");

		for (int i = 0; i < fuzzySetContainer.sizeInput(); i++) {
			System.out.print(" " + fuzzySetContainer.getVariableByType(i, VariableType.INPUT));
		}
		System.out.println();

		for (int i = 0; i < fuzzySetContainer.sizeOutput(); i++) {
			System.out.print(" " + fuzzySetContainer.getVariableByType(i, VariableType.OUTPUT));
		}
		System.out.println();
		control();
	}
}